package cacco.jp.mld.panel.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cacco.jp.mld.panel.dao.UrlDao;
import cacco.jp.mld.panel.entity.UrlEntity;

@Service
public class UrlService {

	@Autowired
	UrlDao urlDao;

	public List<UrlEntity> getAll() {
		return urlDao.getAll();
	}

	public int addUrl(UrlEntity url) {
		return urlDao.add(url);
	}

	public void updateUrl(UrlEntity url) {
		urlDao.update(url);
	}

	public void deleteUrl(Integer id) {
		urlDao.delete(id);
	}

	public List<UrlEntity> getAlByPage(int pageSize, int page, String sidx,
			String sord) {
		return urlDao.getAlByPage(pageSize, page, sidx, sord);
	}

	public boolean isExistUrl(int id) {
		UrlEntity entity = null;
		entity = urlDao.findById(id);
		if (entity != null) {
			return true;
		}
		return false;
	}

	public int getTotalRecords() {
		return urlDao.getTotalRecords();
	}
}